package com.chushouya.manager.constants;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.exception.Ex;

import java.util.Objects;

/**
 * 0普通用户/1回收商/2报价师/3门店老板/4门店员工
 */
public enum UserTypeEnum implements IEnum<Integer> {

    normal_user(0, "普通用户"),
    clerk(5, "业务员"),
    merchant_manager(1, "回收商"),
    merchant_quotation(2, "报价师"),
    store_manager(3, "门店老板"),
    store_employee(4, "门店员工");

    private Integer value;

    private String name;


    UserTypeEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.name;
    }

    public static String getName(Integer value) {
        for (UserTypeEnum thisEnum : UserTypeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.name;
            }
        }
        return "";
    }

    public static UserTypeEnum get(Integer value) {
        for (UserTypeEnum thisEnum : UserTypeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum;
            }
        }
        throw Ex.business("未定义的用户类型");
    }
}
